from sqlmodel import Field, SQLModel, Index
from datetime import datetime

class XMBuyOrder(SQLModel, table=True):
    """XM购买订单"""
    __tablename__ = "t_xm_buy_order"

    # 索引定义
    __table_args__ = (
        Index("idx_uid", "uid", info="用户ID索引"),
        Index("idx_monitorBuyId", "monitorBuyId", info="监控挂单ID索引"),
        Index("idx_archiveId", "archiveId", info="XM藏品ID索引"),
    )

    id: int = Field(default=None, primary_key=True, index=True, description="主键ID")
    uid: int = Field(default=0, index=True, description="用户UID")
    monitorBuyId: int = Field(default=0, index=True, description="监控挂单ID")
    orderId: int = Field(default=0, description="购买订单ID")
    orderNo: str = Field(default="", description="购买订单号")
    goodsId: int = Field(default=0, description="XM藏品ID")
    goodsPrice: int = Field(default=0, description="XM藏品价格")
    archiveId: int = Field(default=0, index=True, description="XM藏品ID")
    archiveName: str = Field(default="", description="XM藏品名称")
    archiveImg: str = Field(default="", description="XM藏品图片")
    platformId: int = Field(default=0, index=True, description="藏品发行平台ID")
    status: int = Field(default=0, index=True, description="订单状态 0-成功 1-失败")
    failMsg: str = Field(default="", description="失败信息")
    createdAt: datetime = Field(default_factory=datetime.now, description="创建时间")
